﻿using CommonLibrary.WFFile;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using DeMountCIM.Framework;
using WFStandard;
namespace DemountCIM.Framework;


public delegate void ChangeLanguageDelegate(SysDef.LanguagePack language, ref ResourceDictionary languageDictionary);
public static class ChangeLanguageService
{
    private static ResourceDictionary languageDictionary;

    public static event ChangeLanguageDelegate OnChangeLanguage;



    public static string GetLanguageValue(string key)
    {
        return Regex.Unescape(languageDictionary[key].ToString());
    }

    public static void ChangeLanguage(SysDef.LanguagePack language)
    {
        Def.SetLanguage(language);
    }

    public static void ChangeLanguagePublish(SysDef.LanguagePack language)
    {
        if (OnChangeLanguage != null)
        {
            OnChangeLanguage(language, ref languageDictionary);
            Def.SetLanguage(language);
        }
    }
}
